//
//  ReadThreeImageCell.m
//  News
//
//  Created by lanou3g on 15/11/11.
//  Copyright © 2015年 songhaowen. All rights reserved.
//

#import "ReadThreeImageCell.h"
#import "UIImageView+WebCache.h"
#import "ReadModel.h"
#import "UIView+Extension.h"

@interface ReadThreeImageCell ()

@property (weak, nonatomic) IBOutlet UIImageView *bigImageView;
@property (weak, nonatomic) IBOutlet UIImageView *firstImageView;
@property (weak, nonatomic) IBOutlet UIImageView *secondImageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *sourceLabel;
@property (weak, nonatomic) IBOutlet UIView *bottomView;


@end

@implementation ReadThreeImageCell

#pragma mark - 初始化cell
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cell_readthree = @"cell_readthree";
    ReadThreeImageCell *cell = [tableView dequeueReusableCellWithIdentifier:cell_readthree];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ReadThreeImageCell" owner:nil options:nil] lastObject];
        cell.bottomView.layer.cornerRadius = 20;
        cell.bottomView.layer.masksToBounds = YES;
    }
    
    return cell;
}

- (void)setModel:(ReadModel *)model
{
    _model = model;
    
    [self.bigImageView sd_setImageWithURL:[NSURL URLWithString:model.img]];
    self.bigImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.bigImageView.layer.masksToBounds = YES;
    
    NSArray *imgArr = model.imgnewextra;
    
    for (int i = 0; i < imgArr.count; i++) {
        NSDictionary *dict = imgArr[i];
        NSString *img = dict[@"imgsrc"];
        if (i == 0) {
            [self.firstImageView sd_setImageWithURL:[NSURL URLWithString:img]];
            self.firstImageView.contentMode = UIViewContentModeScaleAspectFill;
            self.firstImageView.layer.masksToBounds = YES;
        } else {
            [self.secondImageView sd_setImageWithURL:[NSURL URLWithString:img]];
            self.secondImageView.contentMode = UIViewContentModeScaleAspectFill;
            self.secondImageView.layer.masksToBounds = YES;
        }
    }
    
    self.sourceLabel.text = model.source;
    self.sourceLabel.font = [UIFont systemFontOfSize:14];
    self.sourceLabel.textColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.8];
    
    self.titleLabel.text = model.title;
}

- (IBAction)closeReadTip:(UIButton *)sender
{
    
}



@end
